@import "var/color";

$bg-color: #fff;
$bg-hover-color: #f9f9f9;
$bg-front-col: #000;
$font: "Inter", sans-serif;
$invalid-color: #d6513c;
$valid-color: #94d63c;

.p-form-select {
  border-radius: 5px;
  display: inline-block;
  font-family: $font;
  margin: 10px;
  position: relative;
}

.p-form-select::before {
  border-color: #fff transparent transparent;
  border-style: solid;
  border-width: 5px;
  content: "";
  pointer-events: none;
  position: absolute;
  right: 5px;
  top: calc(50% - 3px);
  z-index: 3;
}

.p-form-select::after {
  background: $primary-col;
  border-bottom-right-radius: 5px;
  border-top-right-radius: 5px;
  bottom: 0;
  content: "";
  display: block;
  height: 100%;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
  width: 20px;
}

.p-form-select > select {
  background: $bg-color;
  border: 1px solid #cacaca;
  border-radius: 5px;
  font-size: 14px;
  margin: 0;
  outline: none;
  padding: 5px 30px 5px 10px;
  position: relative;
  width: 100%;
}

.p-form-text:invalid,
.p-form-text-alt:invalid,
.p-form-select > select:invalid {
  border-color: var(--invalid-color);
}

.p-form-text:valid,
.p-form-text-alt:valid,
.p-form-select > select:valid {
  border-color: var(--valid-color);
}

.p-form-text:placeholder-shown,
.p-form-select > select:placeholder-shown {
  border-color: #cacaca;
}

.p-form-text {
  -webkit-appearance: none;
  background: $bg-color;
  border: 1px solid #cacaca;
  border-radius: 5px;
  font-family: $font;
  margin: 10px;
  outline: 0;
  padding: 5px;
  resize: none;
  transition: border-color 200ms;
}

.p-form-text-alt {
  -webkit-appearance: none;
  border: 0px;
  border-bottom: 2px solid #cacaca;
  padding: 10px;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  margin: 10px;
}

.p-form-no-validate:valid,
.p-form-no-validate:invalid,
.p-form-no-validate > select:valid,
.p-form-no-validate > select:invalid {
  border: 1px solid #cacaca;
}

.p-form-text:focus {
  border-color: $primary-col-ac;
}

textarea.p-form-text {
  -webkit-appearance: none;
  height: 100px;
}

.p-form-truncated {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p-form-text[type="password"] {
  font-family: caption;
}

.p-form-label,
.p-form-radio-cont,
.p-form-checkbox-cont {
  font-family: $font;
}

.p-form-label {
  display: block;
}

.p-form-radio-cont,
.p-form-checkbox-cont {
  align-items: center;
  display: inline-flex;
  margin: 0 10px;
}

.p-form-radio-cont > input + span,
.p-form-checkbox-cont > input + span {
  background: $bg-color;
  border: 1px solid #cacaca;
  border-radius: 50%;
  cursor: pointer;
  display: inline-block;
  height: 20px;
  margin-right: 5px;
  position: relative;
  transition: background 0.2s;
  width: 20px;
}

.p-form-radio-cont > input + span:hover {
  background: $bg-hover-color;
}

.p-form-radio-cont > input,
.p-form-checkbox-cont > input {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.p-form-radio-cont > input + span::after {
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  content: "";
  display: block;
  height: 30%;
  left: calc(50% - 15%);
  opacity: 0;
  position: absolute;
  top: calc(50% - 15%);
  transform: scale(2);
  transition: opacity 0.2s, transform 0.3s;
  width: 30%;
}

.p-form-radio-cont > input:checked + span {
  background: $primary-col-ac;
}

.p-form-radio-cont > input:checked + span::after {
  opacity: 1;
  transform: scale(1);
}

.p-form-checkbox-cont > input + span {
  border-radius: 5px;
}

.p-form-checkbox-cont > input:checked + span {
  background: $primary-col-ac;
}

.p-form-checkbox-cont > input + span::before,
.p-form-checkbox-cont > input + span::after {
  background: #fff;
  border-radius: 20px;
  content: "";
  display: block;
  height: 8%;
  position: absolute;
}

.p-form-checkbox-cont > input + span::before {
  right: 30%;
  top: 15%;
  transform: rotate(-65deg);
  transform-origin: top right;
  width: 70%;
}

.p-form-checkbox-cont > input + span::after {
  left: 30%;
  top: 43%;
  transform: rotate(60deg);
  transform-origin: top left;
  width: 40%;
}

.p-form-button {
  background: #fff;
  border: 1px solid #cacaca;
  border-radius: 5px;
  color: #333230;
  display: inline-block;
  font-size: 17px;
  margin: 10px;
  padding: 5px 20px;
  text-decoration: none;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.p-form-send {
  background: $primary-col;
  border: 0;
  color: #fff;
}

.p-form-send:active {
  background: $primary-col-ac;
}

.p-form-invalid,
.p-form-invalid:placeholder-shown,
.p-form-invalid:valid,
.p-form-invalid:invalid {
  border-color: var(--invalid-color);
}

.p-form-valid,
.p-form-valid:placeholder-shown,
.p-form-valid:valid,
.p-form-valid:invalid {
  border-color: var(--valid-color);
}

.p-form-switch {
  --width: 80px;
  cursor: pointer;
  display: inline-block;
}

.p-form-switch > input:checked + span::after {
  left: calc(100% - calc(var(--width) / 2.1));
}

.p-form-switch > input:checked + span {
  background: #60c35b;
}

.p-form-switch > span {
  background: #e0e0e0;
  border: 1px solid #d3d3d3;
  border-radius: 500px;
  display: block;
  height: calc(var(--width) / 2);
  overflow: hidden;
  position: relative;
  transition: all 0.2s;
  width: var(--width);
}

.p-form-switch > span::after {
  background: #f9f9f9;
  border-radius: 50%;
  box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 1px rgba(0, 0, 0, 0.16), 0px 3px 8px rgba(0, 0, 0, 0.15);
  content: "";
  height: 90%;
  left: 3%;
  position: absolute;
  top: 4.5%;
  transition: all 0.2s;
  width: 45%;
}

.p-form-switch > input {
  display: none;
}
